<template>
	<view>
		<u-tabbar :value="value4" @change="name =>change(name)" :fixed="false" :placeholder="false"
			activeColor="#10a07c" :safeAreaInsetBottom="false">
			<u-tabbar-item text="首页" @click='name=>swtab(name)'>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="@/static/icons/shou.png"></image>
				<image class="u-page__item__slot-icon" slot="active-icon" src="@/static/icons/shou3.png"></image>
			</u-tabbar-item>
			<u-tabbar-item text="消息" @click='name=>swtab(name)' :dot='isShow'>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="@/static/icons/xiao.png"></image>
				<image class="u-page__item__slot-icon" slot="active-icon" src="@/static/icons/xiao2.png"></image>
			</u-tabbar-item>
			<u-tabbar-item text="订单" @click='name=>swtab(name)'>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="@/static/icons/dian.png"></image>
				<image class="u-page__item__slot-icon" slot="active-icon" src="@/static/icons/dian2.png"></image>
			</u-tabbar-item>
			<u-tabbar-item text="我的" @click='name=>swtab(name)'>
				<image class="u-page__item__slot-icon" slot="inactive-icon" src="@/static/icons/si1.png"></image>
				<image class="u-page__item__slot-icon" slot="active-icon" src="@/static/icons/si2.png"></image>
			</u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
	import {getNewList} from '../../pages/news/api.js'
	export default {
		props: ['value'],
		data() {
			return {
				value4: this.value,
				isShow:false
			}
		},
		created() {
			let a = uni.getStorageSync('msg')
			if(a == true){
				this.isShow = false
			}else{
				this.isShow = true
			}
			getNewList({page:1,limit:10}).then(res=>{
				if(res.code==200){
					uni.hideLoading()
					this.newsList =res.data
					uni.setStorageSync('msg',res.data[0].is_read)
				}
			})
		},
		methods: {
			swtab(e) {
				this.value4 = e
				switch (e) {
					case 0:
						this.value4 = this.value
						uni.switchTab({
							url: '/pages/index/index'
						})
						break;
					case 1:
						this.value4 = this.value
						uni.switchTab({
							url: '/pages/news/news'
						})
						break;
					case 2:
						this.value4 = this.value
						uni.switchTab({
							url: '/pages/order/order'
						})
						break;
					case 3:
						this.value4 = this.value
						uni.switchTab({
							url: '/pages/mine/mine'
						})
						break;
				}
			},
			change(e) {
				this.value4 = e
			},
		}
	}
</script>

<style>
	.u-page__item__slot-icon {
		width: 40rpx;
		height: 40rpx;
	}
</style>
